package com.ls.x.service;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import com.ls.x.activity.beans.AlertModelBean;
import com.ls.x.activity.beans.ContextBean;
import com.ls.x.activity.beans.RemindItemBean;
import com.ls.x.dao.AlertModeDao;
import com.ls.x.dao.ContextDao;
import com.ls.x.dao.IAlertModeDao;
import com.ls.x.dao.IContextDao;
import com.ls.x.tool.DatabaseHelper;

public class ContextRemindModeService implements IContextRemindModeService {

	private IAlertModeDao alertModeDao;
	private IContextDao contextDao;
	private DatabaseHelper databaseHelper;

	public ContextRemindModeService(DatabaseHelper databaseHelper) {
		this.databaseHelper = databaseHelper;
		this.alertModeDao = new AlertModeDao(databaseHelper);
		this.contextDao = new ContextDao(databaseHelper);
	}

	@Override
	public List<RemindItemBean> getAllRemindItems() {

		List<RemindItemBean> remindItemBeanList = new ArrayList<RemindItemBean>();

		List<ContextBean> contextBeanList = contextDao
				.getContextBeansWhereModeIsNotNull();

		for (ContextBean contextBean : contextBeanList) {
			RemindItemBean remindItemBean = new RemindItemBean();

			AlertModelBean alertModelBean = alertModeDao
					.getAlertModeBeanById(contextBean.getMode());
			remindItemBean.setAlertModelId(alertModelBean.getId());
			remindItemBean.setContextId(contextBean.getId());
			remindItemBean.setAlertModelBean(alertModelBean);
			remindItemBean.setContextBean(contextBean);
			remindItemBeanList.add(remindItemBean);
		}
		return remindItemBeanList;
	}
}


